<xsl:stylesheet 
	version="1.0"
	xmlns:lodin="http://www.weso.org/lodin"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	>
<xsl:output method="text" />
	
<xsl:template match="lodin:indicator">
<xsl:text>
<![CDATA[@prefix wi:     <http://data.foundation.org/webindex#> .
@prefix widataset:     <http://data.foundation.org/webindex/dataset#> .
@prefix wimeasure:     <http://data.foundation.org/webindex/indicator#> .
@prefix widsd:     <http://data.foundation.org/webindex/dsd#> .
@prefix widsd:     <http://data.foundation.org/webindex/measure#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:   <http://www.w3.org/2000/01/rdf-schema#> .
@prefix skos:	<http://www.w3.org/2004/02/skos/core#> .
@prefix dc:		<http://purl.org/dc/elements/1.1/> .
@prefix qb:		<http://purl.org/linked-data/cube#> .
@prefix sdmx-concept:    <http://purl.org/linked-data/sdmx/2009/concept#> .
@prefix sdmx-dimension:  <http://purl.org/linked-data/sdmx/2009/dimension#> .
@prefix sdmx-attribute:  <http://purl.org/linked-data/sdmx/2009/attribute#> .
@prefix sdmx-measure:    <http://purl.org/linked-data/sdmx/2009/measure#> .

]]>

</xsl:text>

wimeasure:<xsl:value-of select="@id" /> a rdf:Property, qb:MeasureProperty ;
	 rdfs:label "<xsl:value-of select="@title" />" ;
     wi:sheet "<xsl:value-of select="@sheet" />" ; 
     wi:indicatorType wi:<xsl:value-of select="@type" /> ;
     wi:component wi:<xsl:value-of select="@component" /> ; 
     wi:subindex wi:<xsl:value-of select="@subindex" /> ; 
     wi:source wi:<xsl:value-of select="@source" /> ; 
     wi:providerLink &lt;<xsl:value-of select="@providerLink" />&gt; ;
   	 rdfs:subPropertyOf sdmx-measure:obsValue;
     .
     
wimeasure:<xsl:value-of select="@id" /> wi:dataRangeMin <xsl:call-template name="dataRange">
 <xsl:with-param name="range"><xsl:value-of select="@dataRangeMin" /></xsl:with-param>
</xsl:call-template> . 

wimeasure:<xsl:value-of select="@id" /> wi:dataRangeMax <xsl:call-template name="dataRange">
 <xsl:with-param name="range"><xsl:value-of select="@dataRangeMax" /></xsl:with-param>
</xsl:call-template> . 



widsd:<xsl:value-of select="@id"/> a qb:DataSetDefinition ;
	qb:component [qb:dimension wi:country ; qb:order 1] ,
	             [qb:dimension wi:year; qb:order 2],
	             [qb:measure wimeasure:<xsl:value-of select="@id" />],
	             [qb:attribute sdmx-attribute:unitMeasure ;
	              qb:componentAttachment qb:DataSet ;
	             ]
	             ;
	qb:sliceKey wi:sliceByCountry .
	
widataset:<xsl:value-of select="@id" /> a qb:DataSet ;
	rdfs:label "<xsl:value-of select="@title" />"  ;
    rdfs:comment "<xsl:value-of select="lodin:description" />" ;
    wi:notes "<xsl:value-of select="lodin:comments" />" ; 
	qb:structure widsd:<xsl:value-of select="@id" /> ;
#	sdmx-attribute:unitMeasure number ?
#	qb:slice list slices ...
    .
<!-- <xsl:apply-templates select="lodin:table" /> -->

</xsl:template>

<xsl:template match="lodin:table">
<!-- Here I could add information about slices for each year... --> 
</xsl:template>

<xsl:template name="addProperty">
 <xsl:param name="id" />
 <xsl:param name="property" />
 <xsl:param name="value" />

<xsl:if test="$value != ''">
<xsl:value-of select="$id" /> <xsl:value-of select="$property"/> <xsl:value-of select="$value" /> .
</xsl:if>

</xsl:template>


<xsl:template name="dataRange">
 <xsl:param name="range" />
 <xsl:choose>
  <xsl:when test="$range = 'Unbounded'">wi:Unbounded</xsl:when>
  <xsl:otherwise><xsl:value-of select="$range" /></xsl:otherwise>
 </xsl:choose>
</xsl:template>


</xsl:stylesheet>